package com.mks.demo.mqtt;

public class Test {

    private static String[] binaryArray = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};

    public static void main(String[] args) {
        System.out.println(Long.valueOf("0CC6", 16));
    }

    /**
     * @param b
     * @return 字节转换为二进制字符串
     */
    public static String byte2BinaryStr(byte b) {
        StringBuilder sb = new StringBuilder();
        int pos = 0;
        //高四位
        pos = (b & 0xF0) >> 4;
        sb.append(binaryArray[pos]);
        //低四位
        pos = b & 0x0F;
        sb.append(binaryArray[pos]);
        return sb.toString();

    }

}
